package xianchengpool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @功能
 * @创建时间 2019/12/26
 * 线程池只有一个线程，再怎么都只有一个线程，能保证顺序
 */
public class T09_SingleThreadPool {
    public static void main(String[] args) {
        ExecutorService service = Executors.newSingleThreadExecutor();
        for(int i=0;i<5;i++){
            final int j = i;
            service.execute(()->{
                System.out.println(j+""+Thread.currentThread().getName());
            });
        }
    }
}
